#include "stdio.h"
#include "tddl_measurement.h"
#include "system_information.h"

void test_hardware_info(){
	PCPUINFO pCpuInfo;
	TSS_RESULT rst;
	if((rst = tddl_measure_initCPUStruct(&pCpuInfo) )!= TDDL_SUCCESS){
		printf("error in tddl, id = %d\n", rst);
		return;
	}
	if((rst = tddl_measure_fillCPUStruct(pCpuInfo) )!= TDDL_SUCCESS){
		printf("error in tddl, id = %d\n", rst);
		return;
	}
	
	printf("CPU Company is : %s\n", pCpuInfo->Company);
	
	if((rst = tddl_measure_freeCPUStruct(&pCpuInfo) )!= TDDL_SUCCESS){
		printf("error in tddl, id = %d\n", rst);
		return;
	}
	
}

void test_software_info(){
	PSOFTINFO pSoftInfo;
	TSS_RESULT rst;
	if((rst = tddl_measure_initSoftStruct(&pSoftInfo) )!= TDDL_SUCCESS){
		printf("error in tddl, id = %d\n", rst);
		return;
	}
	
	if((rst = tddl_measure_fillSoftStruct(pSoftInfo) )!= TDDL_SUCCESS){
		printf("error in tddl, id = %d\n", rst);
		return;
	}	
	
	printf("Softname is : %s\n", pSoftInfo->softname);
	
	if((rst = tddl_measure_freeSoftStruct(&pSoftInfo) )!= TDDL_SUCCESS){
		printf("error in tddl, id = %d\n", rst);
		return;
	}
	
}

void test_program_verify(UINT32 length){
	BYTE* p;
	TSS_RESULT rst;
	p = (BYTE*)calloc(length, sizeof(BYTE));
	if(p == NULL){
		printf("malloc error \n");
		return;
	}
	if((rst = tddl_measure_program_verify(length, p)) != TDDL_SUCCESS){
		printf("error in tddl, id = %d\n",rst);
		return;
	}
	printf("success\n");
	free(p);
}

void test_platform_verify(){

	PCPUINFO pCpu;
	PSOFTINFO pSoft;
	
	pCpu = (PCPUINFO)malloc(sizeof(CPUINFO));
	if(pCpu == NULL)
		return;
	strcpy(pCpu->Company, "Cmy");
	strcpy(pCpu->BaseParam, "Jzd");
	strcpy(pCpu->SerialNumber, "5670");
	strcpy(pCpu->sha1_hash, "sha_1");

	pSoft = (PSOFTINFO)malloc(sizeof(SOFTINFO));
	if(pSoft == NULL)
		return;
	strcpy(pSoft->softname, "xd");
	strcpy(pSoft->version, "v27");
	strcpy(pSoft->sha1_hash, "jiao");
	
	free(pCpu);
	free(pSoft);
}

